<layout name="Public/layout"/>
{:jumps($infos['authority'],CONTROLLER_NAME)}

        <script language="javascript" type="text/javascript">
            //排序按钮的点击事件
            function sort(btnObj) {
                if (btnObj.className == "sort_desc")
                    btnObj.className = "sort_asc";
                else
                    btnObj.className = "sort_desc";
            }

        </script>        

        <!--主要区域开始-->
        <div id="main">
            <form action="" method="">
                <!--排序-->
                <div class="search_add">
                    <div>
<!--                        <input type="button" value="时间" class="sort_asc" onclick="sort(this);" />-->
<!--                        <input type="button" value="基费" class="sort_asc" onclick="sort(this);" />
                        <input type="button" value="时长" class="sort_asc" onclick="sort(this);" />-->
                    </div>
                    <input type="button" value="增加" class="btn_add" onclick="location.href='add';" />
                </div> 

                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                        <tr>
                            <th>ID</th>
                            <th class="width150">名称</th>
                            <th>管理者</th>
                            <th>电话</th>
                            <th>地址</th>
                            <th>创建时间</th>
                            <th class="width50">状态</th>
                            <th class="width200"></th>
                        </tr>  
                        
<volist name="res['res']" id='vo'>                                                   
                        <tr>
                            <td>{$vo.id}</td>
                            <td><a href="__CONTROLLER__/detail/id/{$vo.id}">{$vo.name}</a></td>
                            <td>{$vo.leader}</td>
                            <td>{$vo.tel}</td>
                            <td>{$vo.address}</td>
                            <td>{$vo.create_time}</td>
                            <td>
<if condition="$vo['status'] eq 0 ">
   正常
<else />
   暂停 
</if> 
                            </td>
                            <td>  
<if condition="$vo['status'] eq 0 ">
   <input type="button" value="暂停"  class="btn_pause" onclick="set_status( '__CONTROLLER__/status/id/{$vo.id}/status/1' );" />
<else />
    <input type="button" value="启用"  class="btn_start" onclick="set_status( '__CONTROLLER__/status/id/{$vo.id}/status/0' );" />
</if>   
                                <input type="button" value="修改" class="btn_modify" onclick="location.href='__CONTROLLER__/edit/id/{$vo.id}';" />
                                <input type="button" value="删除" class="btn_delete" onclick="deletes('__CONTROLLER__/delete/id/{$vo.id}');" />
                            </td>
                        </tr>
</volist> 
                        
                    </table>
                    <p>业务说明：<br />
                    1、创建资费时，状态为暂停，记载创建时间；<br />
                    2、暂停状态下，可修改，可删除；<br />
                    3、开通后，记载开通时间，且开通后不能修改、不能再停用、也不能删除；<br />
                    4、业务账号修改资费时，在下月底统一触发，修改其关联的资费ID（此触发动作由程序处理）
                    </p>
                </div>
                <!--分页-->
                <div id="pages">
                    {$res['page']}   
                </div>
            </form>
        </div>
        <!--主要区域结束-->

<script type="text/javascript">
    $(function(){
        //点击之后的图标
        $('.store_off').addClass('store_on').removeClass('store_off');
    });  
</script>

<script type="text/javascript">
    //禁止 开通
    function set_status(obj){
    
        layer.confirm('你确定真的要修改用户状态吗？', {icon: 3, title:'提示'}, function(index){
        if(index){
        
                $.ajax({
                   type: "GET",
                   url: obj,
                   success: function(data){

                            //判断修改加成功！
                            if(data.status==0){
                                layer.msg(data.info,{icon: 5});
                            }else{
                                layer.msg(data.info,{icon: 6});

                                //延迟跳转
                                setTimeout(function () {
                                    location.href = "{:U('Store/index')}";
                                }, {:C('AJAX_TIME')});

                            }

                   }
                });      
        
//        layer.msg(obj);

    }  
      layer.close(index);
    });

    }
    
    
    //删除
    function deletes(obj){
      
    layer.confirm('你确定真的要删除此分店？', {icon: 3, title:'提示'}, function(index){
    if(index){    
        
        $.get(obj, function(data){
            
            //判断是否删除成功！
            if(data.status==0){
                layer.msg(data.info,{icon: 5});
            }else{
                layer.msg(data.info,{icon: 6});

                //延迟跳转
                setTimeout(function () {
                    location.href = "{:U('Store/index')}";
                }, {:C('AJAX_TIME')});

            }
            
        });
        
        
    }  
      layer.close(index);
    });    
        
    }
    
    
</script>